﻿using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule;
using System.Collections.Generic;
using Huirui.Cavan.Domain.MainBoundedContext.SalesModule;
using Huirui.Cavan.Domain.Seedwork;
using Huirui.Cavan.Domain.MainBoundedContext.ReportModule;

namespace Huirui.Cavan.Domain.MainBoundedContext.StockModule
{
    #region Stock

    /// <summary>
    /// Stock object for NHibernate mapped table 'Stock'.
    /// </summary>
    [Serializable]
    public class Stock : Persistent<string>
    {
        #region Member Variables
        protected int _nature;
        protected string _name;
        protected string _specification;
        protected StockType _type;
        protected StockUnit _stockUnit;
        protected string _barCode;
        protected bool _isProxy;
        protected decimal _standardPurchasePrice;
        protected decimal _standardSalesPrice;
        protected decimal _maxPurchasePrice;
        protected decimal _minSalesPrice;
        protected decimal _minLeftNumber;
        protected decimal _leftNumber;
        protected decimal _taxRate;
        protected StockIdentifier.StockStatus _status;
        protected StockIdentifier.StockOnSale _onSale;
        protected Corporation _corporation;
        protected WareHouse _wareHouse;
        protected UnitTransfer _unitTransfer;
        protected IList<PurchaseOrderDetail> _purchaseOrderDetails;
        protected IList<SalesOrderDetail> _salesOrderDetails;
        protected IList<StockExchange> _stockExchanges;
        protected IList<StockExchangeDetail> _stockExchangeDetails;
        protected IList<StockInOutDetail> _stockInDetails;
        protected IList<StockInitialBalance> _stockInitialBalances;
        protected IList<StockOutApplyDetail> _stockOutApplyDetails;


        #endregion

        #region Constructors

        public Stock() { }

        public Stock(string id, int nature, string name, string specification, StockType type, StockUnit stockUnit, string barCode, bool isProxy, decimal standardPurchasePrice, 
            decimal standardSalesPrice, decimal maxPurchasePrice, decimal minSalesPrice, decimal minLeftNumber, decimal taxRate, DateTime createDate, DateTime modifyDate, 
            int editUser, Corporation corporation, WareHouse wareHouse, StockIdentifier.StockStatus status, StockIdentifier.StockOnSale onSale, UnitTransfer unitTransfer)
        {
            this.Id = id;
            this._nature = nature;
            this._name = name;
            this._specification = specification;
            this._type = type;
            this._stockUnit = stockUnit;
            this._barCode = barCode;
            this._isProxy = isProxy;
            this._standardPurchasePrice = standardPurchasePrice;
            this._standardSalesPrice = standardSalesPrice;
            this._maxPurchasePrice = maxPurchasePrice;
            this._minSalesPrice = minSalesPrice;
            this._minLeftNumber = minLeftNumber;
            this._taxRate = taxRate;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._corporation = corporation;
            this._wareHouse = wareHouse;
            this._status = status;
            this._onSale = onSale;
            this._unitTransfer = unitTransfer;
        }

        #endregion

        #region Public Properties

        public virtual int Nature
        {
            get { return _nature; }
            set { _nature = value; }
        }

        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual string Specification
        {
            get { return _specification; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for Specification", value, value.ToString());
                _specification = value;
            }
        }

        public virtual StockType Type
        {
            get { return _type; }
            set { _type = value; }
        }

        public virtual StockUnit StockUnit
        {
            get { return _stockUnit; }
            set
            {
                _stockUnit = value;
            }
        }

        public virtual string BarCode
        {
            get { return _barCode; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for BarCode", value, value.ToString());
                _barCode = value;
            }
        }

        public virtual bool IsProxy
        {
            get { return _isProxy; }
            set { _isProxy = value; }
        }

        public virtual decimal StandardPurchasePrice
        {
            get { return _standardPurchasePrice; }
            set { _standardPurchasePrice = value; }
        }

        public virtual decimal StandardSalesPrice
        {
            get { return _standardSalesPrice; }
            set { _standardSalesPrice = value; }
        }

        public virtual decimal MaxPurchasePrice
        {
            get { return _maxPurchasePrice; }
            set { _maxPurchasePrice = value; }
        }

        public virtual decimal MinSalesPrice
        {
            get { return _minSalesPrice; }
            set { _minSalesPrice = value; }
        }

        public virtual decimal MinLeftNumber
        {
            get { return _minLeftNumber; }
            set { _minLeftNumber = value; }
        }

        public virtual decimal LeftNumber
        {
            get { return _leftNumber; }
            set { _leftNumber = value; }
        }

        public virtual decimal TaxRate
        {
            get { return _taxRate; }
            set { _taxRate = value; }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual WareHouse WareHouse
        {
            get { return _wareHouse; }
            set { _wareHouse = value; }
        }

        public virtual UnitTransfer UnitTransfer
        {
            get { return _unitTransfer; }
            set { _unitTransfer = value; }
        }

        public virtual IList<PurchaseOrderDetail> PurchaseOrderDetails
        {
            get
            {
                if (_purchaseOrderDetails == null)
                {
                    _purchaseOrderDetails = new List<PurchaseOrderDetail>();
                }
                return _purchaseOrderDetails;
            }
            set { _purchaseOrderDetails = value; }
        }

        public virtual IList<SalesOrderDetail> SalesOrderDetails
        {
            get
            {
                if (_salesOrderDetails == null)
                {
                    _salesOrderDetails = new List<SalesOrderDetail>();
                }
                return _salesOrderDetails;
            }
            set { _salesOrderDetails = value; }
        }

        public virtual IList<StockExchange> StockExchanges
        {
            get
            {
                if (_stockExchanges == null)
                {
                    _stockExchanges = new List<StockExchange>();
                }
                return _stockExchanges;
            }
            set { _stockExchanges = value; }
        }

        public virtual IList<StockExchangeDetail> StockExchangeDetails
        {
            get
            {
                if (_stockExchangeDetails == null)
                {
                    _stockExchangeDetails = new List<StockExchangeDetail>();
                }
                return _stockExchangeDetails;
            }
            set { _stockExchangeDetails = value; }
        }

        public virtual IList<StockInOutDetail> StockInDetails
        {
            get
            {
                if (_stockInDetails == null)
                {
                    _stockInDetails = new List<StockInOutDetail>();
                }
                return _stockInDetails;
            }
            set { _stockInDetails = value; }
        }

        public virtual IList<StockInitialBalance> StockInitialBalances
        {
            get
            {
                if (_stockInitialBalances == null)
                {
                    _stockInitialBalances = new List<StockInitialBalance>();
                }
                return _stockInitialBalances;
            }
            set { _stockInitialBalances = value; }
        }

        public virtual IList<StockOutApplyDetail> StockOutApplyDetails
        {
            get
            {
                if (_stockOutApplyDetails == null)
                {
                    _stockOutApplyDetails = new List<StockOutApplyDetail>();
                }
                return _stockOutApplyDetails;
            }
            set { _stockOutApplyDetails = value; }
        }

        public virtual StockIdentifier.StockStatus Status
        {
            get { return _status; }
            set { _status = value; }
        }

        public virtual StockIdentifier.StockOnSale OnSale
        {
            get { return _onSale; }
            set { _onSale = value; }
        }

        public virtual IList<StockByWareHouseReport> StockByWareHouseReports { get; set; }
        #endregion
    }
    #endregion
}